$(document).ready(function(){
    var button = $('#upload_button'), interval;
    new AjaxUpload('#upload_button', {
        //action: 'upload.php',
        action: 'documentos/captura',
        onSubmit : function(file , ext){
        if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext)))
        {
            // extensiones permitidas
            alert('Error: Solo se permiten imagenes');
            // cancela upload
            return false;
        }
        else 
        {
            //Cambio el texto del boton y lo deshabilito
            button.text('Uploading');
            this.disable();
        }
        },
        onComplete: function(file, response){
            button.text('Upload');
            // habilito upload button                      
            this.enable();         
            // Agrega archivo a la lista
            $('#lista').appendTo('.files').text(file);
        }  
    });
});

//	//	//	$(document).ready(function()
//        {           
//            
//       
////            $('#fileInput').change(function () 
////            {
////		sendFile(this.files[0]);
////                
////            });
//// 
////	
////            $('dropZone')[0].ondrop = function (e) 
////            {
////		e.preventDefault();
////		sendFile(e.dataTransfer.files[0]);
////            };
//// 
////            function sendFile(file) 
////            {
////                //alert('-->'+file.fileName);
////                $.ajax({                    
////                            type: 'post',
////                            url: 'documentos/captura?nombre='+file.fileName,
////                            data: file, 
////                            beforeSend: function () {$("#resultado").html("Procesando, espere por favor...");},
////                            success: function (response) {$("#resultado").html(response);},                            
////                            xhrFields: 
////                            {
////                                onprogress: function (progress)
////                                {
////                                    var percentage = Math.floor((progress.total / progress.totalSize) * 100);
////                                    console.log('progress', percentage);
////                                    if (percentage === 100)
////                                    {
////                                        console.log('DONE!');
////                                    }
////                                }
////                            },
////                            processData: false, 
////                            contentType: file.type
////                        });
////             }           
//        });
//
//
////$(document).ready
////(
////    function ()
////    {
////        $("#input_file").change
////        (
////            function(event)
////            {
////                var file = event.target.files[0];
////                $.ajax
////                (
////                    {
////                        beforeSend: function(xhr)
////                        {
////                            xhr.setRequestHeader("nomfile", file.name);
////                        },
////                        type: 'POST',
////                        //url: 'ajax_controller.php',
////                        url: 'archivos.php',
////                        processData: false,
////                        data: file
////                    }
////                );
////            }
////        );
////    }
////);